package com.epin.app;

import com.epin.config.mybatis.DynamicDataSourceRegister;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;

@SpringBootApplication
@ServletComponentScan	//servelet注册
@ComponentScan(basePackages={"com.epin"})
@Import({DynamicDataSourceRegister.class}) // 注册动态多数据源
public class Application extends SpringBootServletInitializer{

	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
	
    public static void main( String[] args ) {
    	ApplicationContext applicationContext = SpringApplication.run(Application.class, args);
		
		String[] beanNames =  applicationContext.getBeanDefinitionNames();
		System.out.println("加载beans的个数：" + beanNames.length);
		for(String bn : beanNames){
			System.out.println(bn);
		}
		
		String[] serviceNames = applicationContext.getBeanNamesForAnnotation(Service.class);
		System.out.println("加载service的个数：" + serviceNames.length);
		for(String sn : serviceNames){
			System.out.println(sn);
		}
    }
}